//
//  DJViewController.swift
//  dj-learn-Swift
//
//  Created by Jaesun on 2020/9/22.
//  Copyright © 2020 S.J. All rights reserved.
//

import UIKit
import RxSwift
import RxCocoa

class DJViewController: UIViewController {
    
    var disposeBag = DisposeBag()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.white
        self.configSubviews()
        self.rx.viewDidAppear.subscribe(onNext: {
            print("view did appear")
        }).disposed(by: self.disposeBag)
    }
    
    func configSubviews() {
        let bgImage = UIImage.create(with: UIColor.init(hex: 0xC83C23, alpha: 1))
        self.navigationController?.navigationBar.isTranslucent = true
        self.navigationController?.navigationBar.setBackgroundImage(bgImage, for: .default)
        self.navigationController?.navigationBar.shadowImage = UIImage.create(with: UIColor.white)
    }

}

public extension Reactive where Base : UIViewController {
    var viewDidAppear: ControlEvent<Void> {
         let source = self.methodInvoked(#selector(Base.viewDidAppear(_:))).map { _ in }
         return ControlEvent(events: source)
     }
}
